#! /usr/bin/env python
# -*- coding: utf-8 -*-
# vim:fenc=utf-8
#
# Copyright © 2018 crane <crane@his-pc>
#
# Distributed under terms of the MIT license.

"""

"""
class Solution:
    def minSubArray(self, nums):
        result = [0] * len(nums)
        min_v = nums[0]
        result[0] = nums[0]

        for i, n in enumerate(nums[1:], 1):
            v = nums[i]
            new_v = result[i-1] + v

            result[i] = min(v, new_v)

            min_v = min(min_v, result[i])

        return min_v


def main():
    print("start main")
    s = Solution()
    ret = s.minSubArray([1, -1, -2, 1])
    print(ret)

if __name__ == "__main__":
    main()
